package cc.comac.mom.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import cc.comac.mom.api.QualityMaterialDataService;
import cc.comac.mom.bean.QualityMaterialData;
import cc.comac.mom.util.ResultBean;

@RestController
@RequestMapping("/QualityMaterialData")
public class QualityMaterialDataController {
	@Autowired
	private QualityMaterialDataService QualityMaterialDataService;

	@RequestMapping(value = "/insert",method = RequestMethod.POST)
	public Object insert(@RequestBody List<QualityMaterialData> QualityMaterialData) {
		ResultBean insertMaterialBatch = QualityMaterialDataService.insertMaterialBatch(QualityMaterialData);
		return insertMaterialBatch;
	}

	// 分页查询所有
	@RequestMapping(value = "/selectAllByPage",method = RequestMethod.POST)
	public ResultBean selectAllByPage(@RequestBody QualityMaterialData QualityMaterialData) {
		ResultBean resultBean = new ResultBean(true);
		try {
			QualityMaterialData selectAllByPage = QualityMaterialDataService.selectAllByPage(QualityMaterialData);
			resultBean.setObject(selectAllByPage);
		} catch (RuntimeException e) {
			resultBean.setErrorMessge(e.getMessage());
			return resultBean;
		}
		return resultBean;
	}
}
